function [caldt , log_return_CTC, log_return_OTC, log_return_CTO , return_CTC , return_OTC , return_CTO , return_OD , return_OR , return_OR_short , ...
    cum_return_CTC ,cum_return_OTC , cum_return_CTO, cum_return_OD, cum_return_OR, cum_return_OR_short, cum_log_return_CTC ,cum_log_return_OTC , cum_log_return_CTO, cum_log_return_OD, ...
    cum_log_return_OR, cum_log_return_OR_short, log_return_OD, log_return_OR, log_return_OR_short] = make_CTO_OTC(file_name,start_date,finish_date,winsorizing,alpha,replace_option)

% ---------------------------------------------------------------------------------- %

% This function creates CTO, OTC and CTC returns. It also creates returns
% for the OD hour and the opening of US markets

data = load(file_name);
caldt = data.caldt_daily;


if strcmp(file_name,'../01_data/es_trades_5minute_EST') == 1
    caldt = data.caldt_daily;
    caldt_mat = data.caldt_mat;
    price = data.price_VWAP_mat;
    log_price = log(price);
elseif strcmp(file_name,'../01_data/es_quotes_5minute_EST') == 1
    caldt = data.caldt_daily;
    caldt_mat = data.caldt_mat;
    price = data.MID_mat;
    log_price = log(price);
elseif strcmp(file_name,'../01_data/ty_quotes_5minute_EST') == 1
    caldt = data.caldt_daily;
    caldt_mat = data.caldt_mat;
    price = data.MID_mat;
    log_price = log(price);
elseif strcmp(file_name,'../01_data/YM_quotes_5minute_EST') == 1
    caldt = data.caldt_daily;
    caldt_mat = data.caldt_mat;
    price = data.MID_mat;
    log_price = log(price);
elseif strcmp(file_name,'../01_data/NQ_quotes_5minute_EST') == 1
    caldt = data.caldt_daily;
    caldt_mat = data.caldt_mat;
    price = data.MID_mat;
    log_price = log(price);
elseif strcmp(file_name,'../01_data/NK_quotes_5minute_EST') == 1
    caldt = data.caldt_daily;
    caldt_mat = data.caldt_mat;
    price = data.MID_mat;
    log_price = log(price);
elseif strcmp(file_name,'../01_data/sp_es_merged_quotes_5minute_EST') == 1
    caldt = data.caldt_daily;
    caldt_mat = data.caldt_mat;
    price = data.MID_mat;
    log_price = log(price); 
end


indx_late_open = find(caldt == datenum('27-Sep-1985'));

log_price(1:indx_late_open,187) = log_price(1:indx_late_open,193);


log_price = forwardfill(log_price,size(log_price,1),size(log_price,2));


log_return_OTC(1) = 0;
log_return_OTC(2:size(log_price,1)) = log_price(2:end,267) - log_price(2:end,187); %close minus open
log_return_OTC = log_return_OTC';
log_return_CTO(1) = 0;
log_return_CTO(2:length(log_return_OTC)) = log_price(2:end,187) - log_price(1:end-1,267); %open minus close
log_return_CTO = log_return_CTO';
log_return_CTC(1) = 0;
log_return_CTC(2:length(log_return_OTC)) = log_price(2:end,267) - log_price(1:end-1,267); %close minus close
log_return_CTC = log_return_CTC';
log_return_OD = log_price(:,108) - log_price(:,96);
log_return_OR = log_price(:,192) - log_price(:,174);


% There's er few NANs for the quotes...
log_return_OTC(isnan(log_return_OTC)) = 0;
log_return_CTO(isnan(log_return_CTO)) = 0;
log_return_CTC(isnan(log_return_CTC)) = 0;
log_return_OD(isnan(log_return_OD)) = 0;
log_return_OR(isnan(log_return_OR)) = 0;

if winsorizing == 1
    log_return_OTC = WinsorizeData(log_return_OTC , alpha, replace_option);
    log_return_CTO = WinsorizeData(log_return_CTO , alpha, replace_option);
    log_return_CTC = WinsorizeData(log_return_CTC , alpha, replace_option);
    log_return_OD = WinsorizeData(log_return_OD , alpha, replace_option);
    log_return_OR = WinsorizeData(log_return_OR , alpha, replace_option);
end

log_return_OR_short = - log_return_OR;

return_OTC = exp(log_return_OTC)-1;
return_CTO = exp(log_return_CTO)-1;
return_CTC = exp(log_return_CTC)-1;
return_OD = exp(log_return_OD)-1;
return_OR = exp(log_return_OR)-1;
return_OR_short = exp(log_return_OR_short)-1;

beg = find_closest(caldt,start_date);
fin = find_closest(caldt,finish_date);
caldt = caldt(beg:fin);

cum_return_OTC = cumprod(1+return_OTC(beg:fin));
cum_return_CTO = cumprod(1+return_CTO(beg:fin));
cum_return_CTC = cumprod(1+return_CTC(beg:fin));
cum_return_OD = cumprod(1+return_OD(beg:fin));
cum_return_OR = cumprod(1+return_OR(beg:fin));
cum_return_OR_short = cumprod(1+return_OR_short(beg:fin));
cum_return_OTC = cum_return_OTC./cum_return_OTC(1);
cum_return_CTO = cum_return_CTO./cum_return_CTO(1);
cum_return_CTC = cum_return_CTC./cum_return_CTC(1);
cum_return_OD = cum_return_OD./cum_return_OD(1);
cum_return_OR = cum_return_OR./cum_return_OR(1);
cum_return_OR_short = cum_return_OR_short./cum_return_OR_short(1);

cum_log_return_OTC = cumsum(log_return_OTC(beg:fin));
cum_log_return_CTO = cumsum(log_return_CTO(beg:fin));
cum_log_return_CTC = cumsum(log_return_CTC(beg:fin));
cum_log_return_OD = cumsum(log_return_OD(beg:fin));
cum_log_return_OR = cumsum(log_return_OR(beg:fin));
cum_log_return_OR_short = cumsum(log_return_OR_short(beg:fin));

log_return_OTC = log_return_OTC(beg:fin);
log_return_CTC = log_return_CTC(beg:fin);
log_return_CTO = log_return_CTO(beg:fin);
log_return_OD = log_return_OD(beg:fin);
log_return_OR = log_return_OR(beg:fin);
log_return_OR_short = log_return_OR_short(beg:fin);

return;
